package o;

import androidx.annotation.NonNull;
import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;

public final class sp extends FilterInputStream {
    private static final int ˊ = (ˏ + 2);
    private static final byte[] ˎ = new byte[]{(byte) -1, (byte) -31, (byte) 0, (byte) 28, (byte) 69, (byte) 120, (byte) 105, (byte) 102, (byte) 0, (byte) 0, (byte) 77, (byte) 77, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 8, (byte) 0, (byte) 1, (byte) 1, (byte) 18, (byte) 0, (byte) 2, (byte) 0, (byte) 0, (byte) 0, (byte) 1, (byte) 0};
    private static final int ˏ = ˎ.length;
    private int ˋ;
    private final byte ॱ;

    public sp(InputStream inputStream, int i) {
        super(inputStream);
        if (i < -1 || i > 8) {
            throw new IllegalArgumentException("Cannot add invalid orientation: " + i);
        }
        this.ॱ = (byte) i;
    }

    public boolean markSupported() {
        return false;
    }

    public void mark(int i) {
        throw new UnsupportedOperationException();
    }

    public int read() throws IOException {
        int read;
        if (this.ˋ < 2 || this.ˋ > ˊ) {
            read = super.read();
        } else if (this.ˋ == ˊ) {
            read = this.ॱ;
        } else {
            read = ˎ[this.ˋ - 2] & 255;
        }
        if (read != -1) {
            this.ˋ++;
        }
        return read;
    }

    public int read(@NonNull byte[] bArr, int i, int i2) throws IOException {
        int read;
        if (this.ˋ > ˊ) {
            read = super.read(bArr, i, i2);
        } else if (this.ˋ == ˊ) {
            bArr[i] = this.ॱ;
            read = 1;
        } else if (this.ˋ < 2) {
            read = super.read(bArr, i, 2 - this.ˋ);
        } else {
            read = Math.min(ˊ - this.ˋ, i2);
            System.arraycopy(ˎ, this.ˋ - 2, bArr, i, read);
        }
        if (read > 0) {
            this.ˋ += read;
        }
        return read;
    }

    public long skip(long j) throws IOException {
        long skip = super.skip(j);
        if (skip > 0) {
            this.ˋ = (int) (((long) this.ˋ) + skip);
        }
        return skip;
    }

    public void reset() throws IOException {
        throw new UnsupportedOperationException();
    }
}
